package com.example.demo.service.impl;

import com.example.demo.annotation.DistributionLock;
import com.example.demo.annotation.DistributionLockParam;
import com.example.demo.entity.Resp;
import com.example.demo.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class OrderServiceImpl implements IOrderService {


    @Override
    @DistributionLock(key = "updateOrderSatus",tryLockTime = 1000)
    public Resp updateOrder(@DistributionLockParam String orderCode, Integer userId, Integer status){
        try {
            log.info("updateOrder 处理业务 start");
            Thread.sleep(1000*10);
            log.info("updateOrder 处理业务 end");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return Resp.buildSuccess("修改订单状态成功");
    }

}
